 <?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
 <link href="<?= STATICURL; ?>css/bootstrap.min.css" rel="stylesheet" />
    <link id="bootstrap-rtl-link" href="" rel="stylesheet" />
    <link id="beyond-link" href="<?= STATICURL; ?>css/beyond.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="<?=STATICURL;?>css/oss_style.css"/>
    <div class="page-content">
     <!-- Page Breadcrumb -->
        <div class="page-breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="fa fa-home"></i>
                    <a href="/luckydog/index">首页</a>
                </li>
                <li class="">
                    <a href="#">招聘管理</a>
                </li>
                <li class="">
                    招聘信息编辑
                </li>
            </ul>
        </div>
        <!-- /Page Breadcrumb -->
        <div class="page-body">
            <div >
                <div id="horizontal-form">
                    <form class="form-horizontal" role="form">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="pull-left" style="line-height: 30px;margin-left: 10px;margin-bottom: 20px;">标题:</div>
                                <div style="float: left; padding-left:10px;">
                                    <input type="text" style="width: 400px;" name="name" placeholder="请输入标题" class="form-control" value="<?= $jobsInfo['name']?>">
                                </div>
                                <div class="horizontal-space"></div>
                            </div>
                            <div class="col-md-6">
                                <div class="pull-left" style="line-height: 30px;margin-left: 0px;margin-bottom: 20px;">招聘人数:</div>
                                <div style="float: left; padding-left:10px;">
                                    <input type="text" style="width: 400px;" name="headcount" placeholder="请输入招聘人数" class="form-control" value="<?=$jobsInfo['headcount']?>">
                                </div>
                                <div class="horizontal-space"></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="pull-left" style="line-height: 30px;margin-left: 25px;margin-bottom: 20px;">省:&nbsp;&nbsp;</div>
                            <div class="col-md-2">
                                <select class="form-control it_province">
                                    <option value="0">---请选择省--</option>
                                    <?php foreach($provinceList as $pro):?>
                                    <option  value="<?= $pro['id']?>"  <?php if($jobsInfo['provinceid'] == $pro['id']):?>selected<?php endif;?>>
                                        <?=$pro['name']?>
                                    </option>
                                    <?php endforeach;?>
                                </select>
                                <div class="horizontal-space"></div>
                            </div>
                            <div class="pull-left" style="line-height: 30px;margin-left: 10px;margin-bottom: 20px;">市:</div>
                            <div class="col-md-2">
                                <select class="form-control it_city">
                                    <option value="0">---请选择市--</option>
                                    <?php foreach($cityList as $city):?>
                                    <option   value="<?= $city['id']?>"  <?php if($jobsInfo['cityid'] == $city['id']):?>selected<?php endif;?>>
                                        <?=$city['name']?>
                                    </option>
                                    <?php endforeach;?>
                                </select>
                                <div class="horizontal-space"></div>
                            </div>
                            <div class="col-md-6">
                                <div class="pull-left" style="line-height: 30px;margin-left: 100px;margin-bottom: 20px;">薪资待遇:</div>
                                <div style="float: left; padding-left:10px;">
                                    <input type="text" style="width: 400px;" name="salary" placeholder="请输入薪资待遇" class="form-control" value="<?=$jobsInfo['salary']?>">
                                </div>
                                <div class="horizontal-space"></div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="pull-left " style="line-height: 30px;margin-left: 10px;margin-bottom: 20px;">排序:</div>
                                <div style="float: left; padding-left:10px;">
                                    <input type="text" style="width: 400px;" name="sort" placeholder="请输入排序(序号越大越靠前)" class="form-control js_sort" value="<?= $jobsInfo['sort']?>">
                                </div>
                                <div class="horizontal-space"></div>
                            </div>
                        </div>
                       <div style="clear:both;margin-top: 20px;"> 
                        <label>招聘详情：</label>
                       
                        <textarea class="form-control contents" rows="3" id="contents" name="contents" placeholder="Content" style="height:500px;width:80%">
                            <?=$jobsInfo['content']?>
                        </textarea>
			            </div>
                        <div class="horizontal-space"></div>
                        <div>
                            <span id="editJobs" class="btn btn-default">提交</span>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <input type="hidden" id="idpalce" value="<?= $jobsInfo['id']?>" />
		
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script src="<?= STATICURL; ?>js/jquery.min.js"></script>
<script src="<?= STATICURL; ?>layer/layer.js"></script>
<script src="<?= STATICURL; ?>kindeditor/kindeditor.js"></script>
<script>
$(".del_pic").live("click",function(){
    $(this).parent().remove();
});
$(".js_sort").bind({
                keyup:function(){
                     var txt = $('.js_sort').val();
                     var reg = /^[\d]+$/;
                     if(!reg.test(txt) ){
                            $(this).val('');
                     }
                },
                focus:function(){
                    if ($(this).val() == 0){
                        $(this).val('');
                    }
                },
                blur:function(){
                    if ($(this).val() == ''){
                        $(this).val(default_order);
                    }                   
                }
        });
KindEditor.ready(function(K) {
    window.editor = K.create('#contents');
});
    $(document).ready(function() {
         $(".it_province").change(function(){
            var privinceid = $(this).val();
			if(privinceid == 0)
			{
				$(".it_city").html('<option value="0">---请选择市--</option>');
				return false;
			}
            $.post("<?=BASEURL?>luckydog/jobs/cityList",{privinceid:privinceid},function(data){
                // console.log(data);
                var _option = '<option value="0">---请选择市--</option>';
                $.each(data,function(index,item){
                    _option += '<option value="'+item.id+'">'+item.name+'</option>';
                });
                $(".it_city").html(_option);
            },'json');
        });

       
        $("#editJobs").click(function(){
           
             editor.sync();//Js获取值时前面添加
            var contents =editor.html();
            

            var name = $("input[name='name']").val();
            var headcount = $("input[name='headcount']").val();
            var salary = $("input[name='salary']").val();
            var sort = $("input[name='sort']").val();
            
            var id = $("#idpalce").val();
            var provinceid = $(".it_province").val();
            var cityid = $(".it_city").val();

            if(name == ""){
                layer.msg("招聘职位不能为空");return false;   
            }
            if(contents == ""){
                layer.msg("内容不能为空");return false;
            }
           
            if(cityid == ""){
                layer.msg("请选择省市");return false;   
            }
	    $.post("<?=BASEURL?>luckydog/jobs/editjobs", {salary:salary,contents:contents,name:name,headcount:headcount,provinceid:provinceid,cityid:cityid,"id":id,'sort':sort}, function(res) {
                if (res) {
                    layer.msg("成功");
                    window.location.href="/luckydog/jobs/index";
                }else{
                    layer.msg("失败");
                }
            });
        });
    });
</script>